﻿#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>

using namespace std;

#include "binarySearchTree.h"
void test1()
{
	Key::BSTree<int> bs;
	int a[] = { 8, 3, 1, 10, 6, 4, 7, 14, 13 };
	for (auto& e : a)
	{
		bs.Insert(e);
	}
	//bs.InOrder();
	/*for (auto& e : a)
	{
		bs.Erase(e);
		bs.InOrder();
	}*/
	//Key::BSTree<int> bsc = bs;
	//bsc.InOrder();
	Key::BSTree<int> bscc;
	bscc = bs;
	//bscc.InOrder();
}

void test2()
{
	key_value::BSTree<string, int> bs;
	string s[] = { "totoro", "totoro", "dongdong", "dudu", "dongdong" };
	for (auto& ch : s)
	{
		if (!bs.Find(ch))
			bs.Insert(ch, 1);
		else
		{
			bs.Find(ch)->_val++;
		}
	}
	bs.InOrder();
	/*for (auto& ch : s)
	{
		bs.Erase(ch);
		bs.InOrder();
	}*/
	key_value::BSTree<string, int> bsc(bs);
	bsc.InOrder();
	key_value::BSTree<string, int> bscc;
	bscc = bs;
	bscc.InOrder();
}
void test3()
{
	string arr[] = { "苹果", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜", "苹果", "香蕉", "苹果", "香蕉" };
	key_value::BSTree<string, int> countTree;
	for (const auto& str : arr)
	{
		// 先查找⽔果在不在搜索树中 
		// 1、不在，说明⽔果第⼀次出现，则插⼊<⽔果, 1> 
		// 2、在，则查找到的结点中⽔果对应的次数++ 
		//BSTreeNode<string, int>* ret = countTree.Find(str);
		auto ret = countTree.Find(str);
		if (ret == NULL)
		{
			countTree.Insert(str, 1);
		}
		else
		{
			ret->_val++;
		}
	}
	 countTree.InOrder();
}
void test4()
{
	key_value::BSTree<string, string> dic;
	dic.Insert("book", "书");
	dic.Insert("totoro", "龙猫");
	dic.Insert("dudu", "嘟嘟");
	//dic.InOrder();
	string word;
	while (cin >> word)
	{
		key_value::BSNode<string, string>* p = dic.Find(word);
		if (p)
		{
			cout << "中文: " << p->_val << endl;
		}
		else
		{
			cout << "俺也不知道什么意思" << endl;
		}

	}
}
int main()
{
	test4();
	return 0;
}